<?php
/**
 * 字段管理
 * @author chenlisong E-mail:chenlisong1021@163.com 
 * @version 创建时间：2015年9月11日 下午12:08:42 
 * 类说明
 */
class FieldsAction extends BaseAction{
	/**
	 * @authority 浏览
	 */
	public function index(){
		$this->display('index');
	}
	
	//列表
	public function getAllData(){
		$Model = M('Fields');
		$map = $this->loadSeachCondition();
		$map['flag'] = 1;
		$total = $Model->where($map)->count();// 查询满足要求的总记录数
		$page = json_decode($this->pageParam($total));
		$data = $Model->where($map)->limit($page->firstRow,$page->listRows)->order($page->sort)->select();
		$vo = $this->toJosnForGird($data,$page);
		echo json_encode($vo);
	}
	
	/**
	 * 组装条件
	 * @return multitype:multitype:string
	 */
	public function loadSeachCondition(){
		$map = array();
		if(!empty($_GET['field'])){
			$map['field'] = array("like","%".$_GET['field']."%");
		}
		return $map;
	}
	
	//图片传图
	public function uploadImgForEditor(){
		import("COM.Core.UploadUtils");
		$upload = new UploadUtils();
		$path = "./Uploads/EditorImg/".date('Y-m-d')."/";
		$result = $upload->uploadImgForEditor($path);
		$result[0]['webRoot'] = C('TMPL_PARSE_STRING.__IMGROOT__');
		$this->ajaxReturn($result);
	}
	
}